package com.li.spark0615.zhibiao

import org.apache.spark.sql.{SaveMode, SparkSession}
import org.apache.spark.sql.functions._

object Ten {
  def main(args: Array[String]): Unit = {


    System.setProperty("HADOOP_USER_NAME","root")

    val session = SparkSession
      .builder()
      .appName("li")
      .master("local[*]")
      .enableHiveSupport()
      .config("hive.metastore.uris", "thrift://192.168.23.40:9083")
      .config("dfs.client.use.datanode.hostname", "true")
      .config("hive.exec.dynamic.partition.mode", "nonstrict")
      .getOrCreate()

    val value = session
      .table("ods.lx_area")
      .where(col("state") === "江西省")
      .limit(1)

    session
      .table("ods.lx_com_log")
        .where(col("sourcedomain") === "51job")
      .as("a")
      .join(
        session.table("ods.lx_com").as("b")
        ,
        col("a.id") === col("b.id")
      ).where(col("b.address") like "%江西省%").select(col("b.name") as "comName"  ,col("b.url") as "comUrl")
      .write
      .format("jdbc")
      .option("url", "jdbc:mysql://192.168.23.40:3306/shtd_store?useSSL=false&characterEncoding=utf8")
      .option("user", "root")
      .option("password", "123456")
      .option("dbtable", "col_10")
      .mode(SaveMode.Overwrite)
      .save()
//    session.table("")

  }
}
